// ******************************************************************
// * Copyright(c)  Steven Lu
// * Description   : Entity_INV_PICKING_ITEMS
// * CreateDate    : 2012/3/5 15:58:58
// * Creater       : CodeSmith
// * LastChangeDate: 2012/3/5 15:58:58
// * LastChanger   : 2012/3/5 15:58:58
// * Version Info  : 1.0 For ESOL
// ******************************************************************

using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Suzsoft.Smart.Data;
using ESOL.Common.Entity;

namespace ESOL.Business.Inv
{
/// <summary>
    /// InvPickingItems
    /// </summary>
    public partial class InvPickingItemsBs
    {
        #region GetByID
        /// <summary>
        /// Get Entity
        /// </summary>
        /// <param name="objInvPickingItemsEntity">Entity</param>
        /// <returns>Entity</returns>
        public static InvPickingItemsEntity GetInvPickingItems(InvPickingItemsEntity objInvPickingItemsEntity)
        {
            return DataAccess.SelectSingle<InvPickingItemsEntity>(objInvPickingItemsEntity);
        }

        public static List<InvPickingItemsEntity> GetByApplication(string appId)
        {
            if (string.IsNullOrEmpty(appId))
            {
                return null;
            }
            InvPickingItemsEntity entity = new InvPickingItemsEntity();
            entity.ApplicationId = appId;
            return DataAccess.Select<InvPickingItemsEntity>(entity);
        }

        public static InvPickingItemsEntity GetById(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                return null;
            }
            InvPickingItemsEntity entity = new InvPickingItemsEntity();
            entity.ItemId = id;
            return DataAccess.SelectSingle<InvPickingItemsEntity>(entity);
        }

        public static DataSet GetDataSetByApplicationID(string appId)
        {
            if (string.IsNullOrEmpty(appId))
            {
                return null;
            }
            string sql = @"SELECT PAI.*,P.*, PT.PRODUCT_TYPE_NAME, PPT.PRODUCT_TYPE_NAME AS PARENT_PRODUCT_TYPE_NAME, PMQ.*,INVS.CURRENT_QTY 
                            FROM INV_PICKING_ITEMS PAI
                            INNER JOIN INV_PICKING_APPLICATION PA ON PA.APPLICATION_ID = PAI.APPLICATION_ID
                            LEFT JOIN MST_PRODUCT P ON P.PRODUCT_ID = PAI.PRODUCT_ID
                            LEFT JOIN MST_PRODUCT_TYPE PT ON PT.PRODUCT_TYPE_ID = P.PRODUCT_TYPE_ID
							LEFT JOIN MST_PRODUCT_TYPE PPT ON PPT.PRODUCT_TYPE_ID = PT.PARENT_TYPE_ID
							LEFT JOIN PROD_MRP_QTY PMQ ON PMQ.PRODUCT_ID = P.PRODUCT_ID
                            LEFT JOIN DBO.INV_STORAGE INVS ON PAI.PRODUCT_ID=INVS.PRODUCT_ID
                            WHERE PAI.APPLICATION_ID = '" + appId + "'";
            return DataAccess.SelectDataSet(sql);
        }
        #endregion

        #region Insert
        /// <summary>
        /// Insert Data
        /// </summary>
        /// <param name="objInvPickingItemsEntity">Entity</param>
        /// <returns>true Insert Succeed; false Insert Fail</returns>
        public static bool InsertInvPickingItems(InvPickingItemsEntity objInvPickingItemsEntity)
        {
            return DataAccess.Insert(objInvPickingItemsEntity);
        }

        public static bool InsertInvPickingItems(List<InvPickingItemsEntity> objInvPickingItemsEntityList)
        {
            return DataAccess.Insert(objInvPickingItemsEntityList);
        }
        #endregion

        #region Update
        /// <summary>
        /// Update Data
        /// </summary>
        /// <param name="objInvPickingItemsEntity">Entity</param>
        /// <returns>true Update Succeed; false Update Fail</returns>
        public static bool UpdateInvPickingItems(InvPickingItemsEntity objInvPickingItemsEntity)
        {
            return DataAccess.Update(objInvPickingItemsEntity);
        }

        public static bool UpdateInvPickingItems(List<InvPickingItemsEntity> objInvPickingItemsEntityList)
        {
            return DataAccess.Update<InvPickingItemsEntity>(objInvPickingItemsEntityList);
        }
        #endregion

        #region Delete
        /// <summary>
        /// Delete Data
        /// </summary>
        /// <param name="objInvPickingItemsEntity">Entity</param>
        /// <returns>true Delete Succeed; false Delete Fail</returns>
        public static bool DeleteInvPickingItems(InvPickingItemsEntity objInvPickingItemsEntity)
        {
            return DataAccess.Delete(objInvPickingItemsEntity);
        }

        public static bool DeleteInvPickingItems(List<InvPickingItemsEntity> objInvPickingItemsEntityList)
        {
            return DataAccess.Delete<InvPickingItemsEntity>(objInvPickingItemsEntityList);
        }
        #endregion

        #region GetAll
        /// <summary>
        /// Get All Data
        /// </summary>
        /// <returns>Back All Data<returns>
        public static DataSet GetInvPickingItemsAll()
        {
            return DataAccess.SelectAllDataSet<InvPickingItemsEntity>();
        }
        /// <summary>
        /// Get All Data List
        /// </summary>
        /// <returns>Back All Data List<returns>
        public static List<InvPickingItemsEntity> GetInvPickingItemsAllList()
        {
            return DataAccess.SelectAll<InvPickingItemsEntity>();
        }
        #endregion
	}
	
	
}	

